import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data: {
      username: data.username,
      password: data.password,
      geetest_challenge: data.validate.geetest_challenge,
      geetest_seccode: data.validate.geetest_seccode,
      geetest_validate: data.validate.geetest_validate,
      gtServer: data.gtServer
    }
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout(token) {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

/* 获取极验验证码 */
export function getGeetest() {
  return request({
    url: '/geetest',
    method: 'get'
  })
}

export function getList(data) {
  return request({
    url: '/user/list',
    method: 'get',
    params: data
  })
}

export function getStore(data) {
  return request({
    url: '/user/store',
    method: 'get',
    params: data
  })
}

export function getAllRoles(data) {
  return request({
    url: '/user/role_all',
    method: 'get',
    params: data
  })
}

export function handle(data) {
  return request({
    url: '/user/handle',
    method: 'post',
    data: data
  })
}

export function deleteUser(data) {
  return request({
    url: '/user/delete',
    method: 'post',
    data: data
  })
}
